const { Controller } = require('varal');

class CarController extends Controller {
	async index() {
		const carService = this.app.service('CarService');
		const { category_id, city_code } = this.app.fields;

		const data = await carService.get({ category_id, city_code }, 1, 1000).then(({ data }) => data);

		this.app.json({
			err_code: 0,
			data
		})
	}

	async info() {
		const { id } = this.app.fields;
		const carService = this.app.service('CarService');
		const data = await carService.info({ id });

		//购车注意事项
		const { order_attention } = await this.app.service('ConfigService').info();
		data.order_attention = order_attention;

		this.app.json({
			err_code: 0,
			data
		})
	}
}

exports = module.exports = CarController;
